﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ApplicationGenerator.BusinessModule.Interfaces;

namespace ApplicationGenerator.CommonForms.Forms
{
    public partial class ParameterInConfigurationControl : UserControl
    {
        public IMetaModel MetaModel
        {
            private get;
            set;
        }

        public string ParameterName
        {
            get
            {
                return labelParameterName.Text;
            }
            set
            {
                labelParameterName.Text = value;
            }
        }

        public Type ParameterType
        {
            private get;
            set;
        }

        public string MappedField
        {
            get
            {
                return textBoxMappedField.Text;
            }

            set
            {
                textBoxMappedField.Text = value;
            }
        }


        public ParameterInConfigurationControl(IMetaModel metaModel)
        {
            MetaModel = metaModel;

            InitializeComponent();
        }

        public ParameterInConfigurationControl(IMetaModel metaModel, string parameterName, string mappedField)
        {
            MetaModel = metaModel;
            ParameterName = parameterName;
            MappedField = mappedField;

            InitializeComponent();
        }

        private void buttonChoose_Click(object sender, EventArgs e)
        {
            SelectModelFieldForm selectFieldForm = new SelectModelFieldForm(MetaModel);
            if (DialogResult.OK != selectFieldForm.ShowDialog())
            {
                return;
            }

            MappedField = selectFieldForm.Path;
        }
    }
}
